package code

const (
	SUCCESS       = 200
	ERROR         = 500
	InvalidParams = 10001

	LoginSuccess    = 1017
	RegisterSuccess = 1018

	// 验证码
	CaptchaParamsErr         = 10021
	CaptchaErr               = 10022
	CaptchaVerifyCodeInvalid = 10023

	// 用户
	UserExist             = 10031
	UserNotExist          = 10032
	UserPwdNotMatch       = 10033
	UserEnabled           = 10034
	GetUserPowerErr       = 10035
	InsertUserErr         = 10036
	UserNotPerms          = 10037
	EmailExist            = 10039
	MobileExist           = 10040
	UserInfoNotPermission = 10041
	PasswordNotPass       = 10042

	TokenEmptyErr       = 10051
	TokenInvalidErr     = 10052
	TokenExpireErr      = 10055
	TokenNotRefresh     = 10054
	TokenRefreshSuccess = 10056

	GetMenuDataErr  = 10071
	SaveMenuDataErr = 10072

	RoleExist = 10091

	UpdateErr     = 10110
	UpdateSuccess = 10111

	StatusUnauthorized = 10121
)

var statusText = map[int]string{
	SUCCESS:       "操作成功",
	ERROR:         "服务器错误",
	InvalidParams: "请求参数错误",

	LoginSuccess:    "登录成功",
	RegisterSuccess: "注册成功",

	CaptchaParamsErr:         "验证码缺少重要参数",
	CaptchaErr:               "验证码有误",
	CaptchaVerifyCodeInvalid: "验证码无效",

	UserExist:             "用户已存在",
	UserNotExist:          "用户不存在",
	UserPwdNotMatch:       "账号或密码不正确",
	UserEnabled:           "账号已被锁定,请联系管理员",
	GetUserPowerErr:       "获取用户权限数据失败",
	InsertUserErr:         "新增用户失败",
	UserNotPerms:          "无权限",
	EmailExist:            "邮箱已存在",
	MobileExist:           "手机号已存在",
	UserInfoNotPermission: "没有权限获取该用户信息",
	PasswordNotPass:       "原密码不正确",

	TokenEmptyErr:       "token为空",
	TokenInvalidErr:     "token无效",
	TokenExpireErr:      "token已过期",
	TokenNotRefresh:     "当前token不能刷新",
	TokenRefreshSuccess: "token刷新成功",

	StatusUnauthorized: "unauthorized",

	GetMenuDataErr:  "获取用户菜单数据失败",
	SaveMenuDataErr: "保存菜单数据失败",

	RoleExist: "角色已存在",

	UpdateErr:     "更新失败",
	UpdateSuccess: "更新成功",
}

func StatusText(code int) string {
	str, ok := statusText[code]
	if ok {
		return str
	}
	return statusText[ERROR]
}
